package hiho.ku._1068;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	private static final int[] twos = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576};

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());
		
		final double log2 = Math.log(2);
		final int m = (int) Math.floor(Math.log(n) / log2);
		
		final int[][] f = new int[n + 1][m + 1];
		for (int i = 1; i <= n; i++)
			f[i][0] = Integer.valueOf(br.readLine());
		for (int i = 1; i <= m; i++)
			for (int j = 1; j + twos[i] - 1 <= n; j++)
				f[j][i] = Math.min(f[j][i - 1], f[j + twos[i - 1]][i - 1]);
		
		int q = Integer.valueOf(br.readLine());
		for (int i = 0; i < q; i++) {
			String[] tmps = br.readLine().split(" ");
			int x = Integer.valueOf(tmps[0]);
			int y = Integer.valueOf(tmps[1]);
			int p = (int) Math.floor(Math.log(y - x + 1) / log2);
			System.out.println(Math.min(f[x][p], f[y - twos[p] + 1][p]));
		}
	}

}

//#include <cstdio>
//#include <cmath>
//
//int twos[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576};
//int f[1000001][21];
//
//int main()
//{
//	double logTwo = log(2);
//
//	int n, m;
//	scanf("%d", &n);
//	m = (int) floor(log(n) / logTwo);
//
//	for (int i = 1; i <= n; i++)
//		scanf("%d", &f[i][0]);
//	for (int i = 1; i <= m; i++)
//		for (int j = 1; j + twos[i] - 1 <= n; j++)
//			f[j][i] = (f[j][i - 1] < f[j + twos[i - 1]][i - 1])? f[j][i - 1] : f[j + twos[i - 1]][i - 1];
//
//	int q;
//	scanf("%d", &q);
//	for (int i = 0; i < q; i++)
//	{
//		int x, y;
//		scanf("%d %d", &x, &y);
//		int p = (int) floor(log(y - x + 1) / logTwo);
//		printf("%d\n", (f[x][p] < f[y - twos[p] + 1][p])? f[x][p] : f[y - twos[p] + 1][p]);
//	}
//
//	return 0;
//}
